<%-- 
    Document   : MemberInfo
    Created on : 2020-4-20, 19:34:55
    Author     : zhang
--%>

<%@page import="dao.BookDao"%>
<%@page import="entity.Book"%>
<%@page import="entity.Address"%>
<%@page import="dao.AddressDao"%>
<%@page import="entity.OrderInfo"%>
<%@page import="entity.OrderForm"%>
<%@page import="dao.OrderDao"%>
<%@page import="java.util.List"%>
<%@page import="entity.Member"%>
<%@page import="dao.MemberDao"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>用户信息</h1>
        <div style="position:absolute;left:500px">
                <h3><a href="Admin.jsp">返回管理界面</a></h3>
            </div>
        <%
            int userId=Integer.parseInt(request.getParameter("userid"));
            Member member=new MemberDao().getMemberById(userId);
        %>
        <h3>姓名：<%=member.getName()%></h3>
        <h3>性别：<%=member.getGender()%></h3>
        <h3>手机号：<%=member.getPhone()%></h3>
        <h3>邮箱：<%=member.getEmail()%></h3>
        <h3>职业：<%=member.getProfession()%></h3>
        <h3>感兴趣书籍：<%=member.getLiketype()%></h3>
        
        <h1>订单列表</h1>
        <table>
                    <tr>
                        <th>订单号</th><th>订单时间</th><th>地址</th><th>收件人</th>
                        <th>书名</th><th>件数</th>
                    </tr>
                    <%
                            List<OrderForm> orderformList=new OrderDao().getAllOrderForm(userId);
                            for(OrderForm orderform:orderformList){
                                List<OrderInfo> orderinfoList=new OrderDao().getOrderInfo(orderform.getId());
                                Address address=new AddressDao().getAddressById(orderform.getAddressId());
                    %>
                        <tr>
                            <td><%=orderform.getId()%></td><td><%=orderform.getOrderDate()%></td>
                            <td><%=address.getAddress()%></td><td><%=address.getAddressee()%></td>
                            <td><ul>
                        <%
                                for(int i=0;i<orderinfoList.size();i++){
                                    Book book=new BookDao().getBookById(orderinfoList.get(i).getBookId());                                   
                        %>
                                            <li><%=book.getBookName()%></li>                            
                        <%
                                }
                        %>
                                </ul></td>
                                <td><ul>
                         <%
                                        for(int i=0;i<orderinfoList.size();i++){
                                                Book book=new BookDao().getBookById(orderinfoList.get(i).getBookId());
                         %>
                                    <li><%=orderinfoList.get(i).getCount()%></li>
                         <%
                                }
                         %>
                                </ul></td><td><a href="OrderDetail.jsp?orderid=<%=orderform.getId()%>&userid=<%=userId%>">查看详情</a></td>
                          <%
                                 }
                           %>
                </table>
    </body>
</html>
